﻿using System;
using System.Collections.Generic;
using System.Text;

namespace NVR.BLL
{
    public class NVRDevInfo
    {
        private DALFactory.DALFactory dataFactory = DataProvider.DefaultProvider;
        public int AddNvr(Entity.NVRDeviceInfo obj)
        {
            return dataFactory.DALNVRDevInfoProvider.Insert(obj);
        }

        public int UpdateNvr(Entity.NVRDeviceInfo obj)
        {
            return dataFactory.DALNVRDevInfoProvider.Update(obj);
        }

        public int Delete(string sn)
        {
            Entity.NVRDeviceInfo nvrInfo=new Entity.NVRDeviceInfo();
            nvrInfo.deviceSN=sn;
            return dataFactory.DALNVRDevInfoProvider.Delete(nvrInfo);
        }

        /// <summary>
        /// 查询NVR信息，
        /// </summary>
        /// <param name="sn">Sn</param>
        /// <returns>如果查询到则返回NVR结构信息，否则返回NULL</returns>
        public Entity.NVRDeviceInfo GetNVRInfoBySn(string sn)
        {
            return  dataFactory.DALNVRDevInfoProvider.LoadById(sn);
        }

        public List<Entity.NVRDeviceInfo> GetPages(int currentPages, int pageSize, out int counts, out int pageNums, string username)
        {
            return dataFactory.DALNVRDevInfoProvider.PagePartFunc(currentPages, pageSize, out counts, out pageNums, username);
        }

        public int GetNvrNums(string username)
        {
            return dataFactory.DALNVRDevInfoProvider.GetNvrNums(username);
        }
    }
}
